package com.ywicc.usblibs.comm;

/**
 * author : zhouxuan77
 * e-mail : zhouxuan77@163.com
 * time   : 2022/03/27
 * desc   : 主车、从车通讯协议封装
 * version: V4.3
 */
public class CommCarUtils {

    public final static int CAR_STOP = 0X01;
    public final static int CAR_GO = 0X02;
    public final static int CAR_BACK = 0X03;
    public final static int CAR_TURN_LEFT = 0X04;
    public final static int CAR_TURN_RIGHT = 0X05;
    public final static int CAR_TRACKING = 0X06;
    public final static int CAR_ENCODER_RESET = 0X07;
    public final static int CAR_FRONT_INFRARED = 0X10;
    public final static int CAR_BEHIND_INFRARED = 0X11;
    public final static int CAR_START_INFRARED = 0X12;
    public final static int CAR_LIGHT = 0X20;
    public final static int CAR_BUZZER = 0X30;
    public final static int CAR_PHOTO_UP = 0x50;
    public final static int CAR_PHOTO_DOWN = 0x51;
    public final static int CAR_LIGHT_SOURCE_ADD_ONE = 0X61;
    public final static int CAR_LIGHT_SOURCE_ADD_TWO = 0X62;
    public final static int CAR_LIGHT_SOURCE_ADD_THREE = 0X63;
    public final static int CAR_UPLOAD_AGV_DATA = 0X80;
    public final static int CAR_SPEECH_RECOGNITION = 0X90;

    public byte[] getMainCarData(int type, int first, int second, int third) {
        byte checkData = (byte) ((type + first + second + third) % 256);

        return new byte[]{0x55, (byte) 0xAA, (byte) type, (byte) first, (byte) second, (byte) third, checkData, (byte) 0xBB};
    }

    public byte[] getSubCarData(int type, int first, int second, int third) {
        byte checkData = (byte) ((type + first + second + third) % 256);

        return new byte[]{0x55, 0x02, (byte) type, (byte) first, (byte) second, (byte) third, checkData, (byte) 0xBB};
    }
}
